cmake_minimum_required(VERSION 3.10)
project(IndustrialRemoteExpertSupportSystem LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

find_package(Qt5 REQUIRED COMPONENTS Core Gui Network Sql Widgets Concurrent Multimedia MultimediaWidgets)

add_definitions(-DQT_DEPRECATED_WARNINGS)

# 通用
file(GLOB COMMON_SOURCES
  "src/common/*.cpp"
)
add_library(common STATIC
  ${COMMON_SOURCES}
)
target_link_libraries(common Qt5::Core Qt5::Network)
target_include_directories(common PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/common)

# 添加FFmpeg库
find_library(AVFORMAT_LIBRARY avformat)
find_library(AVCODEC_LIBRARY avcodec)
find_library(AVUTIL_LIBRARY avutil)
find_library(SWSCALE_LIBRARY swscale)

# 服务端
file(GLOB SERVER_SOURCES
  "src/server/*.cpp"
  "src/server/user/*.cpp"
  "src/server/room/*.cpp"
  "src/server/manager/*.cpp"
  "src/server/worker/*.cpp"
)

add_executable(server
  ${SERVER_SOURCES}
)
target_link_libraries(server common Qt5::Core Qt5::Network Qt5::Sql Qt5::Multimedia Qt5::MultimediaWidgets Qt5::Widgets)

# 客户端
file(GLOB CLIENT_SOURCES
  "src/client/*.cpp"
  "src/client/DB/*.cpp"
  "src/client/camera/*.cpp"
  "src/client/room/*.cpp"
  "src/client/image/*.cpp"
  "src/client/audio/*.cpp"
  "src/client/text/*.cpp"
  "src/client/thread/*.cpp"
  "src/client/invitation/*.cpp"
  "src/client/window/join/*.cpp"
  "src/client/window/main/*.cpp"
  "src/client/window/me/*.cpp"
  "src/client/window/login/*.cpp"
  "src/client/window/video/*.cpp"
  "src/client/window/InviteExpert/*.cpp"
)

add_executable(client
  ${CLIENT_SOURCES}
)
target_link_libraries(client common Qt5::Core Qt5::Network Qt5::Sql Qt5::Multimedia Qt5::MultimediaWidgets Qt5::Widgets Qt5::Concurrent)
target_link_libraries(client
    ${AVFORMAT_LIBRARY}
    ${AVCODEC_LIBRARY}
    ${AVUTIL_LIBRARY}
    ${SWSCALE_LIBRARY}
)

# 添加包含目录
target_include_directories(client PRIVATE 
    /usr/include/x86_64-linux-gnu
    ${CMAKE_CURRENT_BINARY_DIR}  # 添加构建目录以包含生成的UI头文件
)